package com.heima.wemedia.controller;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.dtos.WmMaterialDto;
import com.heima.model.common.enums.WmMaterial;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 自媒体素材表(WmMaterial)表控制层
 *
 * @author makejava
 * @since 2022-04-10 17:49:41
 */
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    /**
     * 服务对象
     */
    @Resource
    private WmMaterialService wmMaterialService;

@PostMapping("/upload_picture")
public ResponseResult uploadPic(MultipartFile multipartFile) throws IOException {
    return wmMaterialService.uploadPic(multipartFile);
}
@PostMapping("/list")
    public ResponseResult<WmMaterial> selectList(@RequestBody WmMaterialDto wmMaterialDto){

    return wmMaterialService.selectList(wmMaterialDto);
}
@GetMapping("/del_picture/{id}")
    public ResponseResult delectById(@PathVariable("id") int id){

    return wmMaterialService.deleteById(id);
}
@GetMapping("/collect/{id}")
    public ResponseResult isCollection(@PathVariable("id") int id){
    return wmMaterialService.isCollection(id);
}
@GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable("id") int id){
    return wmMaterialService.cancelCollect(id);
}

}

